$(function () {
  // url参数
  var params = location.search.substr(7).split(','); //取得整个地址栏
  console.log('params:', params);
  window.sessionStorage.setItem('start_date',params[0]);
  window.sessionStorage.setItem('end_date',params[1]);
  $('.login_box>form>p:nth-of-type(3)').on('click',function () {
        var username = $('#username').val();
        if (!username) {
            $('#err').css("display", "block");
            $('#err').text("*请输入账号");
            return;
        }
        // else if (!(/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/).test(username)) {
        //     $('#err').css("display", "block");
        //     $('#err').text("*请输入正确手机号");
        //     return;
        // }
        else {
            $('#err').css("display", "none");
        }
        var userpwd = $('#userpwd').val();
        if (userpwd == '') {
            $('#pwderr').css("display", "block");
            return;
        } else {
            $('#pwderr').css("display", "none");
        }
		var name = $('#username').val();
		var pwd = $('#userpwd').val();
        $('#login_in').text("登录中...");
		$.ajax({
			type:'POST',
			async:true,
            cache: false,
            crossDomain: true == !(document.all),
            // crossDomain: true,
			url:'http://c.yueshengkj.com/api/auth/loginToShow',
			data:{mobile:name,password:pwd},
			dataType:'json',
			success:function(data){
				if (data.status_code == 200) {
                    $('#login_in').text("登录");
                    console.info(data.data)
                    window.sessionStorage.setItem('api_token',data.data.token);
                    window.sessionStorage.setItem('tr_id',data.data.userInfo?data.data.userInfo.bindResort.tr_id:null);
                    window.sessionStorage.setItem('tr_name',data.data.userInfo?data.data.userInfo.bindResort.tr_name:'');
                    window.sessionStorage.setItem('userInfo',JSON.stringify(data.data.userInfo));
                    window.sessionStorage.setItem('num1',0);
                    window.sessionStorage.setItem('num2',0);
                    window.location.href = "./index.html";
				}else {
                    $('#login_in').text("登录");
					$('#errmsg').text(data.msg).css("display", "block");										
				}
			}
		})
	});
})